<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="./lib/vue.js"></script>
    <style>
        .red {
            color: red;
        }

        .thin {
            font-weight: 200;
        }

        .italic {
            font-style: italic;
        }

        .active {
            letter-spacing: 0.5em;
        }
    </style>
</head>

<body>
    <div id="app">
        <h1 class="red thin">这是标题H1</h1>

        <!-- 使用v-bind来绑定属性 -->
        <!-- 第一种方式,直接传递一个数组 -->
        <h1 :class="['red','thin']">这是标题H1</h1>
        <!-- 在数组里使用三元表达式 -->
        <h1 :class="['red','thin',flag?'active':'']">这是标题H1</h1>
        <h1 :class="['red','thin',flag?'':'active']">这是标题H1</h1>
        <!-- 换一种写法,对象形式代替三元表达式 -->
        <h1 :class="['red','thin',{'active':flag}]">这是标题H1</h1>
        <h1 :class="['red','thin',{'':flag}]">这是标题H1</h1>
        <!-- 直接使用对象 -->
        <h1 :class="{red:true,thin:true,active:true}">这是标题H1</h1>
        <h1 :class="{red:true,thin:true,active:false}">这是标题H1</h1>
        <!--  -->
        <h1 :class="classObj">这是标题H1</h1>
    </div>
</body>
<script>
    var vm = new Vue({
        el: "#app",
        data: {
            flag: true,
            classObj:{
                red: true,
                thin:false,
                active:true
            }
        },
        methods: {

        }
    });
</script>

</html>